using UnityEngine;

public class CheckClickInRect
{
	private Camera _camera;

	public Camera Camera
	{
		get
		{
			if (null == _camera)
			{
				_camera = UICamera.currentCamera;
			}
			return _camera;
		}
		set
		{
			_camera = value;
		}
	}

	public bool InRange(UIRect rect, Vector2 position)
	{
		Vector3[] array = new Vector3[4]
		{
			Camera.WorldToScreenPoint(rect.worldCorners[0]),
			Camera.WorldToScreenPoint(rect.worldCorners[1]),
			Camera.WorldToScreenPoint(rect.worldCorners[2]),
			Camera.WorldToScreenPoint(rect.worldCorners[3])
		};
		if (position.x > array[0].x && position.y > array[0].y && position.x > array[1].x && position.y < array[1].y && position.x < array[2].x && position.y < array[2].y && position.x < array[3].x && position.y > array[3].y)
		{
			return true;
		}
		return false;
	}

	public bool InRangeHorizontal(UIRect rect, Vector2 position)
	{
		Vector3[] array = new Vector3[4]
		{
			Camera.WorldToScreenPoint(rect.worldCorners[0]),
			Camera.WorldToScreenPoint(rect.worldCorners[1]),
			Camera.WorldToScreenPoint(rect.worldCorners[2]),
			Camera.WorldToScreenPoint(rect.worldCorners[3])
		};
		return position.x > array[0].x && position.x > array[1].x && position.x < array[2].x && position.x < array[3].x;
	}
}
